<?php
/**
 * @Notes:【】
 * @Date: 2022-08-04 23:36
 */

namespace App\Controller\Admin\Ocean;

use App\Controller\Admin\BaseController;
use App\Service\Ocean\OceanFishService;
use App\Service\Ocean\OceanRubbishService;
use Hyperf\Di\Annotation\Inject;
use Yj\Apidog\Annotation\ApiController;
use Yj\Apidog\Annotation\FormData;
use Yj\Apidog\Annotation\PostApi;

/**
 * @Notes:【】
 * @Date: 2022-08-04 23:47
 * @ApiController(prefix="admin/ocean/rubbish")
 */
class OceanRubbishController extends BaseController
{
    /**
     * @Inject()
     * @var OceanRubbishService
     */
    protected $oceanRubbishService;

    /**
     * @PostApi(path="lists")
     */
    public function lists()
    {
        $params = $this->getParams();
        $data = $this->oceanRubbishService->lists($params);
        _SUCCESS($data);
    }

    /**
     * @PostApi(path="add")
     * @FormData(key="name")
     * @FormData(key="price")
     * @FormData(key="picture")
     * @FormData(key="grow_time")
     */
    public function add()
    {
        $params = $this->getParams();
        $data = $this->oceanRubbishService->add($params);
        _SUCCESS();
    }

    /**
     * @PostApi(path="edit")
     * @FormData(key="name")
     * @FormData(key="id")
     * @FormData(key="price")
     * @FormData(key="picture")
     * @FormData(key="grow_time")
     */
    public function edit()
    {
        $params = $this->getParams();
        $this->oceanRubbishService->edit($params->get('id'), $params->except('id'));
        _SUCCESS();
    }
}